home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr47 / wasm223.zip / RECEIVE < prev    next >
Text File  |  1993-05-04  |  2KB  |  47 lines

  1. // 
  2. // SESSION Receive Routines, By Eric Tauck
  3. //
  4. // Requires:
  5. //
  6. //   STRING
  7. //   TIMER
  8. //
  9.  
  10. Receive_End JUMP
  11.  
  12. // --------------------------------------------
  13. // Wait for a byte. Must call TimerReset first.
  14. // --------------------------------------------
  15.  
  16. : WaitForByte                           // ( - 0 | byte -1)
  17.   : WaitForByte1
  18.   CGET ?DUP NOT WaitForByte2 ?JUMP ;    // get byte, exit if returned
  19.   : WaitForByte2                        // byte not returned
  20.   BREAK TimerExpired CALL               // break and check if time expired
  21.   NOT WaitForByte1 ?JUMP                // loop back if not
  22.   FALSE ;                               // timeout
  23.  
  24. // ------------------------------------------
  25. // Wait for a string. Return TRUE if success.
  26. // ------------------------------------------
  27.  
  28. : WaitForString                         // (string ticks - 0 | -1)
  29.   TimerReset CALL                       // reset timer
  30.   : WaitForString1
  31.   DUP WaitForStringChar ForString? CALL // try receiving string
  32.   ?DUP NOT WaitForString2 ?JUMP         // jump if unsuccessful
  33.     SWAP DROP ;                         // success, exit
  34.   : WaitForString2
  35.   TimerExpired CALL                     // check if time expired
  36.   NOT WaitForString1 ?JUMP              // loop back if not
  37.   DROP FALSE ;                          // timeout
  38.  
  39. : WaitForStringChar                     // (byte - 0 | -1)
  40.   WaitForByte CALL                      // wait for a byte
  41.   WaitForStringChar1 ?JUMP              // jump if byte returned
  42.     DROP FALSE ;                        // no byte, exit
  43.   : WaitForStringChar1                  // byte returned
  44.   DUP CREP = ;                          // replace and compare byte
  45.  
  46. : Receive_End
  47.